package com.briup.spring_swagger.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
//springboot中对swagger2的支持
@EnableSwagger2
@Configuration
public class Swagger2Config {
    /**
     * 1.设置在线文档显示基本信息：
     * 2.需要配置扫描controller的包路径
     */
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.briup.spring_swagger.web.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    //swagger界面中显示的基本信息
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("学生管理系统")
                .description("欢迎访问briup官网，http://www.briup.com")
                .termsOfServiceUrl("http://www.briup.com")
                .version("1.0")
                .build();
    }
}
